package com.szgz.platform.model;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 老师创建的共享环境的学生使用记录（子表）
 */
@TableName("teacher_environment_usage")
@Data
public class TeacherEnvironmentUsage {

    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    private String id;

    @TableField("environment_id")
    private String environmentId; // 关联 TeacherEnvironment

    @TableField("student_id")
    private String studentId; // 关联 User.userId

    @TableField("student_no")
    private String studentNo;

    @TableField("username")
    private String username;

    @TableField("display_name")
    private String displayName; // 姓名

    @TableField("access_url")
    private String accessUrl;

    @TableField("access_username")
    private String accessUsername;

    @TableField("access_password")
    private String accessPassword;

    @TableField("work_dir")
    private String workDir;

    @TableField("token")
    private String token;

    @TableField("allocated_port")
    private String allocatedPort;

    @TableField("service_type")
    private String serviceType; // 具体服务类型（继承自父环境，可覆盖）：MYSQL/JUPYTER/REDIS/IDE/...

    @TableField("service_config")
    private String serviceConfig; // JSON 扩展配置，不同服务所需的额外参数

    @TableField("db_username")
    private String dbUsername;

    @TableField("db_password")
    private String dbPassword;

    @TableField("db_name")
    private String dbName;

    @TableField("last_access_at")
    private LocalDateTime lastAccessAt;

    @TableField("created_at")
    private LocalDateTime createdAt;

    @TableField("updated_at")
    private LocalDateTime updatedAt;

    @TableLogic
    @TableField("deleted")
    private Integer deleted;

    public TeacherEnvironmentUsage() {
        this.createdAt = LocalDateTime.now();
        this.updatedAt = LocalDateTime.now();
        this.deleted = 0;
    }


}

